/* ascii_gyro.h - Copyright (C) 2014 James Boyle

   This program is free software: you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation, either version 3 of the License, or
   (at your option) any later version.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program.  If not, see <http://www.gnu.org/licenses/>.*/
#ifndef ASCII_GYRO_HEADER_INCLUDED
#define ASCII_GYRO_HEADER_INCLUDED

/* gyro codes */
#define GYRO_ONE_TOGGLE_CODE 'X'
#define GYRO_TWO_TOGGLE_CODE 'Y'
#define GYRO_ONE_MAPPING_START 0x00
#define GYRO_ONE_MAPPING_END 0x1F
#define GYRO_TWO_MAPPING_START 0x20
#define GYRO_TWO_MAPPING_END 0x3F
#define GYRO_MAP_SEQUENCE_CODE 'Z'
#define GYRO_MONO_CODE 'O'
#define GYRO_SEQUENCER_CODE 'S'
#define GYRO_LOOP_CODE 'L'
#define GYRO_NEXT_SEQ_POS_CODE '^'

/* gyro constants */
#define GYRO_FIRST_TONE -1
#define GYRO_COUNT 2
#define OCTAVE_TONES 12
#define SEQUENCES 64
#define RECORD_MAX 256
enum { GYRO_ONE = 0, GYRO_TWO };
enum { MONO_MODE, SEQUENCER_MODE };

/* the sequencer struct contains all internal data used by the gyroscope
   controlled sequencer */
typedef struct sequencer
{
	char sequence[RECORD_MAX];
	char recorded[SEQUENCES][RECORD_MAX];
	int sequence_len, sequence_pos;
	int recorded_len[SEQUENCES], recorded_pos;
} SEQUENCER;

int gyro_synth(const char ch);
int gyro_mono_synth(const char ch);
int gyro_sequencer(const char ch);

#endif
